<?php

function get_title()
{
   $requete = "select title from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->title);
}

function get_logpath()
{
   $requete = "select logpath from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->logpath);
}

function get_rootpwd()
{
   $requete = "select rootpwd from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->rootpwd);
}

function get_coverspath()
{
   $requete = "select coverspath from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->coverspath);
}

function get_picspath()
{
   $requete = "select picspath from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->picspath);
}

function get_language()
{
   $requete = "select language from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->language);
}

function enable_soap()
{
   $requete = "select enable_soap from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->enable_soap);
}

function get_soap_client()
{
   $requete = "select client_soap from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->client_soap);
}

function get_max_record()
{
   $requete = "select max_record from config";
   $resultat = biblio_db_query($requete);
   $object=biblio_next_object($resultat);
   return ($object->max_record);
}

function get_book_amazon_isbn($isbn)
{
#   $proxy_tab = array ( 'proxy_host' => "10.0.10.2",
#   			'proxy_port' => 8080
#		);
   $soap_client = get_soap_client();
   $client = new SoapClient ($soap_client);

   $params   = array(
    'asin'	   => "$isbn",
    'mode'         => 'books',
    'sort'         => '+title',
    'type'         => 'lite',
    'tag'          => 'trachtenberg-20',
    'devtag'       => 'XXXXXXXXXXXXXX',
    'locale'	   => 'fr'
   );
   $return=$client->ASINSearchRequest($params);
   return($return);
}

function return_isbn($rechcode)
{
  if (strlen($rechcode) == 13)
  {
    #recreate the isbn
    $rechcode=substr($rechcode,3);
    $rechcode=substr($rechcode,0,-1);
    $check=0;
    for ($i=0; $i<strlen($rechcode); $i++)
    {
       $check=$check+($i+1)*$rechcode[$i];
    }
    $rechcode=$rechcode . $check % 11;
  }
  return($rechcode);
}
?>
